package com.example.demo.vo

import com.example.demo.dao.TJzrInfoDao
import com.example.demo.dbmodels.TJzrBed
import com.example.demo.dbmodels.TJzrInfo
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import me.liuwj.ktorm.dsl.QueryRowSet
import java.math.BigDecimal
import java.time.LocalDateTime

@ApiModel(description = "病人信息")
class InfoVo {

    @ApiModelProperty("病人ID")
    var id: Long = -1

    @ApiModelProperty(value = "入院次数")
    var series: Int? = -1

    @ApiModelProperty("住院号")
    var admissionId: String = ""

    @ApiModelProperty("病人姓名")
    var name: String = ""

    @ApiModelProperty("性别")
    var sex: String = ""

    @ApiModelProperty("民族")
    var nation: String = ""

    @ApiModelProperty("科室代码")
    var deptCode: Int? = -1

    @ApiModelProperty("科室名称")
    var deptName: String = ""

    @ApiModelProperty("病区代码")
    var wardCode: Int? = -1

    @ApiModelProperty(value = "病区名称")
    var wardName: String = ""

    @ApiModelProperty("床位号")
    var bedNo: String = ""

    @ApiModelProperty("出生日期")
    var birthday: LocalDateTime? = null

    @ApiModelProperty("年龄")
    var age: String = ""

    @ApiModelProperty("联系电话")
    var phone: String = ""

    @ApiModelProperty("家庭住址")
    var address: String = ""

    @ApiModelProperty("职业")
    var professional: String = ""

    @ApiModelProperty("联系方式")
    var contactInfo: String = ""

    @ApiModelProperty("体重")
    var weight: Double? = 0.0

    @ApiModelProperty("身高")
    var height: Double? = 0.0

    @ApiModelProperty("入院时间")
    var admissionTime: LocalDateTime? = null

    @ApiModelProperty("入科时间")
    var admissionWardTime: LocalDateTime? = null

    @ApiModelProperty("出院时间")
    var dischargeTime: LocalDateTime? = null

    @ApiModelProperty("入院诊断")
    var diagnosis: String = ""

    @ApiModelProperty("护理级别")
    var nursingClass: String = ""

    @ApiModelProperty("病人病情")
    var patientCondition: String = ""

    @ApiModelProperty("医保费别代码")
    var chargeType: Int? = -1

    @ApiModelProperty("医保费别名称")
    var chargeTypeName: String = ""

    @ApiModelProperty("总花费")
    var totalCost: BigDecimal? = null

    @ApiModelProperty("预缴金额")
    var prePayment: BigDecimal? = null

    @ApiModelProperty("自付金额")
    var selfPayment: BigDecimal? = null

    @ApiModelProperty("余额")
    var balance: BigDecimal? = null

    @ApiModelProperty("欠费标识")
    var arrearFlag: String = ""

    @ApiModelProperty("饮食信息")
    var diet: String = ""

    @ApiModelProperty("主治医生代码")
    var doctorCode: String = ""

    @ApiModelProperty("主治医生姓名")
    var doctorName: String = ""

    @ApiModelProperty("病人状态")
    var status: String = ""

    @ApiModelProperty("过敏史")
    var allergy: String = ""

    fun getVo(table: TJzrInfo): InfoVo {
        table.let {
            val data = InfoVo()
            data.id = it.ID
            data.address = it.ADDRESS
            data.admissionId = it.ADMISSION_ID
            data.admissionTime = it.ADMISSION_TIME
            data.admissionWardTime = it.ADMISSION_WARD_TIME
            data.age = it.AGE
            data.allergy = it.ALLERGY
            data.arrearFlag = it.ARREAR_FLAG
            data.balance = it.BALANCE
            data.bedNo = it.BED_NO
            data.birthday = it.BIRTHDAY
            data.chargeType = it.CHARGE_TYPE
            data.chargeTypeName = it.CHARGE_TYPE_NAME
            data.contactInfo = it.CONTACT_INFO
            data.deptCode = it.DEPT_CODE
            data.deptName = it.DEPT_NAME
            data.diagnosis = it.DIAGNOSIS
            data.diet = it.DIET
            data.dischargeTime = it.DISCHARGE_TIME
            data.doctorCode = it.DOCTOR_CODE
            data.doctorName = it.DOCTOR_NAME
            data.height = it.HEIGHT
            data.name = it.NAME
            data.nation = it.NATION
            data.nursingClass = it.NURSING_CLASS
            data.patientCondition = it.PATIENT_CONDITION
            data.phone = it.PHONE
            data.prePayment = it.PRE_PAYMENT
            data.professional = it.PROFESSIONAL
            data.selfPayment = it.SELF_PAYMENT
            data.series = it.SERIES
            data.sex = it.SEX
            data.status = it.STATUS
            data.totalCost = it.TOTAL_COST
            data.wardCode = it.WARD_CODE
            data.wardName = it.WARD_NAME
            data.weight = it.WEIGHT
            return data
        }
    }

    fun getListVo(table: List<TJzrInfo>): List<InfoVo> {
        table.let {
            val listInfoVo = mutableListOf<InfoVo>()
            table.forEach {
                val data = InfoVo()
                data.id = it.ID
                data.address = it.ADDRESS
                data.admissionId = it.ADMISSION_ID
                data.admissionTime = it.ADMISSION_TIME
                data.admissionWardTime = it.ADMISSION_WARD_TIME
                data.age = it.AGE
                data.allergy = it.ALLERGY
                data.arrearFlag = it.ARREAR_FLAG
                data.balance = it.BALANCE
                data.bedNo = it.BED_NO
                data.birthday = it.BIRTHDAY
                data.chargeType = it.CHARGE_TYPE
                data.chargeTypeName = it.CHARGE_TYPE_NAME
                data.contactInfo = it.CONTACT_INFO
                data.deptCode = it.DEPT_CODE
                data.deptName = it.DEPT_NAME
                data.diagnosis = it.DIAGNOSIS
                data.diet = it.DIET
                data.dischargeTime = it.DISCHARGE_TIME
                data.doctorCode = it.DOCTOR_CODE
                data.doctorName = it.DOCTOR_NAME
                data.height = it.HEIGHT
                data.name = it.NAME
                data.nation = it.NATION
                data.nursingClass = it.NURSING_CLASS
                data.patientCondition = it.PATIENT_CONDITION
                data.phone = it.PHONE
                data.prePayment = it.PRE_PAYMENT
                data.professional = it.PROFESSIONAL
                data.selfPayment = it.SELF_PAYMENT
                data.series = it.SERIES
                data.sex = it.SEX
                data.status = it.STATUS
                data.totalCost = it.TOTAL_COST
                data.wardCode = it.WARD_CODE
                data.wardName = it.WARD_NAME
                data.weight = it.WEIGHT
                listInfoVo.add(data)
            }
            return listInfoVo
        }
    }


    fun getVo(queue: QueryRowSet): InfoVo {
        queue.let {
            val infoVo = InfoVo()
            infoVo.name = it[TJzrInfoDao.NAME].toString()
            infoVo.address = it[TJzrInfoDao.ADDRESS].toString()
            infoVo.admissionId = it[TJzrInfoDao.ADMISSION_ID].toString()
            infoVo.admissionWardTime = it[TJzrInfoDao.ADMISSION_TIME]
            infoVo.age = it[TJzrInfoDao.AGE].toString()
            infoVo.allergy = it[TJzrInfoDao.ALLERGY].toString()
            infoVo.admissionWardTime = it[TJzrInfoDao.ADMISSION_WARD_TIME]
            infoVo.arrearFlag = it[TJzrInfoDao.ARREAR_FLAG].toString()
            infoVo.balance = it[TJzrInfoDao.BALANCE]
            infoVo.bedNo = it[TJzrInfoDao.BED_NO].toString()
            infoVo.birthday = it[TJzrInfoDao.BIRTHDAY]
            infoVo.chargeType = it[TJzrInfoDao.CHARGE_TYPE]
            infoVo.chargeTypeName = it[TJzrInfoDao.CHARGE_TYPE_NAME].toString()
            infoVo.contactInfo = it[TJzrInfoDao.CONTACT_INFO].toString()
            infoVo.deptCode = it[TJzrInfoDao.DEPT_CODE]
            infoVo.deptName = it[TJzrInfoDao.DEPT_NAME].toString()
            infoVo.diagnosis = it[TJzrInfoDao.DIAGNOSIS].toString()
            infoVo.diet = it[TJzrInfoDao.DIET].toString()
            infoVo.dischargeTime = it[TJzrInfoDao.DISCHARGE_TIME]
            infoVo.doctorCode = it[TJzrInfoDao.DOCTOR_CODE].toString()
            infoVo.doctorName = it[TJzrInfoDao.DOCTOR_NAME].toString()
            infoVo.height = it[TJzrInfoDao.HEIGHT]
            infoVo.id = it[TJzrInfoDao.ID]!!
            infoVo.nation = it[TJzrInfoDao.NATION].toString()
            infoVo.nursingClass = it[TJzrInfoDao.NURSING_CLASS].toString()
            infoVo.patientCondition = it[TJzrInfoDao.PATIENT_CONDITION].toString()
            infoVo.phone = it[TJzrInfoDao.PHONE].toString()
            infoVo.prePayment = it[TJzrInfoDao.PRE_PAYMENT]
            infoVo.professional = it[TJzrInfoDao.PROFESSIONAL].toString()
            infoVo.selfPayment = it[TJzrInfoDao.SELF_PAYMENT]
            infoVo.series = it[TJzrInfoDao.SERIES]
            infoVo.sex = it[TJzrInfoDao.SEX].toString()
            infoVo.status = it[TJzrInfoDao.STATUS].toString()
            infoVo.totalCost = it[TJzrInfoDao.TOTAL_COST]
            infoVo.wardCode = it[TJzrInfoDao.WARD_CODE]
            infoVo.wardName = it[TJzrInfoDao.WARD_NAME].toString()
            infoVo.weight = it[TJzrInfoDao.WEIGHT]
            return infoVo
        }
    }

}